package com.woniu.adopt.mapper;

import com.woniu.adopt.entity.Manager;
import com.woniu.adopt.vo.ManagerVo;
import com.woniu.adopt.vo.TeamVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ManagerMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Manager record);

    Manager selectByPrimaryKey(Integer id);

    List<Manager> selectAll();

    int updateByPrimaryKey(ManagerVo record);

    @Select("select * from t_manager where username = #{value}")
    Manager selectManageByName(String name);

    List<ManagerVo> selectManagerByName(String name);

    void insertManager(ManagerVo managerVo);

    void insertRoleToManager(@Param("mid") Integer id, @Param("roleArr") int[] roleIds);

    @Select("select r.name from t_manager_role mr inner join t_role r on mr.role_id = r.id where mr.manager_id = #{id}")
    List<String> selectRoleNamesByMid(int mid);

    @Delete("delete from t_manager_role where manager_id=#{mid}")
    void removeRoleByMid(@Param("mid") Integer id);

    @Update("update t_manager set del=0,update_time=now() where id=#{value}")
    int doRecycle(int id);

    @Select("select count(id) from t_manager where username=#{value}")
    int judgedSameName(String userName);
}